#!/usr/bin/env python

PACKAGE="realsense_camera"

from dynamic_reconfigure.parameter_generator_catkin import *

gen = ParameterGenerator()

#             Name                                         Type      Level  Description                                   Default    Min     Max
gen.add("enable_depth",                                    bool_t,   0,     "Enable Depth",                               True)
gen.add("color_backlight_compensation",                    int_t,    0,     "Backlight Compensation",                     0,         0,      4)
gen.add("color_brightness",                                int_t,    0,     "Brightness",                                 0,         0,      255)
gen.add("color_contrast",                                  int_t,    0,     "Contrast",                                   50,        16,     64)
gen.add("color_gain",                                      int_t,    0,     "Gain",                                       64,        0,      256)
gen.add("color_gamma",                                     int_t,    0,     "Gamma",                                      300,       100,    280)
gen.add("color_hue",                                       int_t,    0,     "Hue",                                        0,         -2200,  2200)
gen.add("color_saturation",                                int_t,    0,     "Saturation",                                 64,        0,      255)
gen.add("color_sharpness",                                 int_t,    0,     "Sharpness",                                  50,        0,      7)

gen.add("color_enable_auto_exposure",                      int_t,    0,     "Enable Color Auto Exposure",                 1,         0,      1)
# Must be set only if color_enable_auto_exposure is disabled
gen.add("color_exposure",                                  int_t,    0,     "Color Exposure",                             166,      50,   666)

gen.add("color_enable_auto_white_balance",                 int_t,    0,     "Enable Auto White Balance",                  1,         0,      1)
# Must be set only if color_enable_auto_white_balance is disabled
gen.add("color_white_balance",                             int_t,    0,     "White Balance",                              4600,      2000,   8000)

gen.add("r200_lr_auto_exposure_enabled",                   int_t,    0,     "Enable LR Auto Exposure",                    0,         0,      1)
# Must be set only if r200_lr_auto_exposure_enabled is disabled
gen.add("r200_lr_exposure",                                int_t,    0,     "LR Exposure",                                164,       1,      164)

gen.add("r200_lr_gain",                                    int_t,    0,     "LR Gain",                                    400,       100,    6399)
gen.add("r200_emitter_enabled",                            int_t,    0,     "Emitter Enabled",                            1,         0,      1)
gen.add("r200_depth_clamp_min",                            int_t,    0,     "Depth Clamp Min",                            0,         0,      65535)
gen.add("r200_depth_clamp_max",                            int_t,    0,     "Depth Clamp Max",                            65535,     0,      65535)

# Depth Control Grouping
r200_depth_control = gen.add_group("R200 Depth Control")
r200_dc_preset_enum = gen.enum(
  [ gen.const("UNUSED",     int_t,  -1, "Individual Depth Control was changed"),
    gen.const("Default",    int_t,  0,  "Default settings on chip. Similar to Medium. Best for Outdoors."),
    gen.const("Off",        int_t,  1,  "Disable almost all hardware-based outlier removal."),
    gen.const("Low",        int_t,  2,  "Lower number of outliers removed. Minimal false negatives."),
    gen.const("Medium",     int_t,  3,  "Medium number of outliers removed. Balanced approach."),
    gen.const("Optimized",  int_t,  4,  "Medium-High number of outliers removed. Derived optimization function."),
    gen.const("High",       int_t,  5,  "Higher number of outliers removed. Minimal false positives.")],
    "Depth Control Preset Choices")
#                      Name
#   Type      Level       Description                         Default   Min     Max     Method
r200_depth_control.add("r200_dc_preset",
    int_t,    64,         "R200 Depth Control Preset",        5,        -1,     5,      edit_method=r200_dc_preset_enum)
r200_depth_control.add("r200_dc_estimate_median_decrement",
    int_t,    32,         "Estimate Median Decrement",        5,        0,      255)
r200_depth_control.add("r200_dc_estimate_median_increment",
    int_t,    32,         "Estimate Median Increment",        5,        0,      255)
r200_depth_control.add("r200_dc_median_threshold",
    int_t,    32,         "Median Threshold",                 235,      0,      1023)
r200_depth_control.add("r200_dc_score_minimum_threshold",
    int_t,    32,         "Score Minimum Threshold",          27,       0,      1023)
r200_depth_control.add("r200_dc_score_maximum_threshold",
    int_t,    32,         "Score Maximum Threshold",          420,      0,      1023)
r200_depth_control.add("r200_dc_texture_count_threshold",
    int_t,    32,         "Texture Count Threshold",          8,        0,      31)
r200_depth_control.add("r200_dc_texture_difference_threshold",
    int_t,    32,         "Texture Difference Threshold",     80,       0,      1023)
r200_depth_control.add("r200_dc_second_peak_threshold",
    int_t,    32,         "Second Peak Threshold",            70,       0,      1023)
r200_depth_control.add("r200_dc_neighbor_threshold",
    int_t,    32,         "Neighbor Threshold",               90,       0,      1023)
r200_depth_control.add("r200_dc_lr_threshold",
    int_t,    32,         "LR Threshold",                     12,       0,      2047)

gen.add("fisheye_exposure",                                int_t,    0,     "Fisheye Exposure",                           40,        40,     331)
gen.add("fisheye_gain",                                    int_t,    0,     "Fisheye Gain",                               0,         0,      2047)
gen.add("fisheye_enable_auto_exposure",                    int_t,    0,     "Fisheye Enable Auto Exposure",               1,         0,      1)
gen.add("fisheye_auto_exposure_mode",                      int_t,    0,     "Fisheye Auto Exposure Mode",                 0,         0,      2)
gen.add("fisheye_auto_exposure_antiflicker_rate",          int_t,    0,     "Fisheye Auto Exposure Antiflicker Rate",     60,        50,     60)
gen.add("fisheye_auto_exposure_pixel_sample_rate",         int_t,    0,     "Fisheye Auto Exposure Pixel Sample Rate",    1,         1,      3)
gen.add("fisheye_auto_exposure_skip_frames",               int_t,    0,     "Fisheye Auto Exposure Skip Frames",          2,         0,      3)
gen.add("frames_queue_size",                               int_t,    0,     "Frames Queue Size",                          20,        1,      20)
gen.add("hardware_logger_enabled",                         int_t,    0,     "Hardware Logger Enabled",                    0,         0,      1)

exit(gen.generate(PACKAGE, "realsense_camera", "zr300_params"))
